﻿using System.Data.Common;

namespace Portal.Workflow.Model
{
    public class WfDefineParamCls
    {
        public string UserId;
        public string LoginName;
        public string RoleId;
        public string RecordId;
        public string WorkflowDefId;
        public string XmlWorkflowData;
        public WfParamCls[] Params = new WfParamCls[] { };
        public DbTransaction dbTransaction;
    }

    public class ViewRenderParamCls : WfDefineParamCls
    {
        public string ViewId;
    }
    public class ReturnViewRenderParamCls : WfDefineParamCls
    {
        public string Html = "";
        public bool ViewAsHtml = false;
    }

    public class WorkflowCheckParamCls : WfDefineParamCls
    {
        
    }

    public class ReturnWorklowCheckParamCls : WfDefineParamCls
    {
        public bool CheckOk;
    }

    public interface IWorkflowCheckNext
    {
        string Id { get; }
        string Name { get; }
        string Description { get; }
        ReturnWorklowCheckParamCls Check(WorkflowCheckParamCls oWorkflowCheckParamCls);
    }

    public interface IWorkflowDef
    {
        string Id { get; }
        string Name { get; }
        string Description { get; }
        ReturnViewRenderParamCls View(
            ViewRenderParamCls oViewRenderParamCls);
        IWorkflowCheckNext[] SupportWorkflowCheckNext { get; }
    }


    public class WorkflowDefTemplate : IWorkflowDef
    {
        public virtual string Id { get { return null; } }
        public virtual string Name { get { return null; } }
        public virtual string Description { get { return null; } }
        public virtual ReturnViewRenderParamCls View(
            ViewRenderParamCls oViewRenderParamCls)
        {
            return null;
        }
        public virtual IWorkflowCheckNext[] SupportWorkflowCheckNext
        {
            get
            {
                return new IWorkflowCheckNext[0];
            }
        }
        public IWorkflowCheckNext FindWorkflowCheckNext(string WorkflowCheckNextId)
        {
            for (int iIndex = 0; iIndex < SupportWorkflowCheckNext.Length; iIndex++)
            {
                if (SupportWorkflowCheckNext[iIndex].Id.Equals(WorkflowCheckNextId))
                {
                    return SupportWorkflowCheckNext[iIndex];
                }
            }
            return null;
        }
    }

    public class WorkflowCheckNextTemplate : IWorkflowCheckNext
    {
        public virtual string Id { get { return null; } }
        public virtual string Name { get { return null; } }
        public virtual string Description { get { return null; } }
        public virtual ReturnWorklowCheckParamCls Check(WorkflowCheckParamCls oWorkflowCheckParamCls) { return null; }

        
    }
}
